/*********************************** (C) COPYRIGHT ******************************
 * address: https://gitee.com/liuniansihuo/multitasks-os
 *
 * Change Logs:
 * Date			Author      	Notes
 * 2019-06-29	LiuHuo			first version
 *
*******************************************************************************/

#define os_task_C_

#include "os_sys.h"
#include "sys_config.h"
#include "os_task_driver.h"
#if SYS_COMPENT_TIMER
#include "timer.h"
#endif
#include "work.h"




/********************************************************************************
*										zhe first task creat
*********************************************************************************/
static void syssvc_run(void)
{
    os_iwdg_reload();
}
static void syssvc_main_run(void)
{
#if SYS_COMPENT_TIMER
	run_timer();
#endif
	work_process();
    syssvc_run();
}
static void syssvc_peripheral_sleep(void)
{}

static void syssvc_message_process(E_DATAID DatID, const u32 data)
{
	switch(DatID)
	{
		default:break;
	}
}

static void syssvc_variable_init(void)
{
    os_iwdg_init(3200);
}

CONSTRUCTOR_DEFAUTL()
void syssvc_task_create(void)
{
	struct task_s task = TASK_DEFAULT_INIT();

	task.ID 		= TASKID_SYS;
	task.state		= TASK_STAT_FREE;
	task.TaskTime	= 0;
	task.run 		= syssvc_main_run;
	task.sleep_init = syssvc_peripheral_sleep;
	task.msg_process= syssvc_message_process;
	task.task_tick 	= NULL;
	task.is_used 	= 1;
	task.task_init  = syssvc_variable_init;
	sys_task_add(&task);
}

CONSTRUCTOR_LEVEL(150)
void __init__(void)
{
	os_clock_init();
    systick_init();
}

